from django import template
from ..models import ArticlePost, ArticleColumn, TaggableManager

register = template.Library()


# 最新文章
@register.simple_tag
def get_recent_articles(num=3):
    return ArticlePost.objects.all().order_by('-created')[:num]


# 推荐文章
@register.simple_tag
def get_popular_articles(num=3):
    return ArticlePost.objects.all().order_by('-total_views')[:num]
